require "tushare_pro/tushare_pro"
$TusharePro = TusharePro::TusharePro.new

$StockToday = []

$Markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new, autolink: true, tables: true)

module Kernel
  # times = 执行次数 ｜ delay_millisencond = 延时毫秒(100 => 100ms)
  # delay_millisecond(100, 300){puts "=========================="}
  def delay_millisecond(times, delay_millisecond, &block)
    times.times do |y|
      time_start = Time.now
      100000000000000000000.times do |z|
        time_end = Time.now
        if (time_end - time_start) > delay_millisecond/1000.0
          yield
          break
        end
      end
    end
  end

  def request_retry(retry_times, error_message = "网络", &block)
    begin
      yield
    rescue => e
      retry_times -= 1
      retry if retry_times >= 0
      puts "#{error_message}"
      puts "error：#{e}"
    end
  end
end